//
// Copyright (C) 2011 - 2013  Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1
//#include "stdafx.h"
#include "SampledCurve.h"
using namespace Cephei::QL::Math;
#include <gen/QL/Math/Array.h>
#undef HANDLE
#undef ABSTRACT
#undef STRUCT
Cephei::QL::Math::CSampledCurve::CSampledCurve (Cephei::QL::Math::IArray^ grid) 
{
	_pSpinlock = new boost::detail::spinlock ();
    CArray^ _Cgrid;
    try
    {
#ifdef HANDLE
        _phSampledCurve = NULL;
#endif
        _Cgrid = safe_cast<CArray^> (grid);
        _Cgrid->Lock();
        QuantLib::Array& _grid = static_cast<QuantLib::Array&> (_Cgrid->GetReference ()); 
        _ppSampledCurve = new boost::shared_ptr<QuantLib::SampledCurve> (new QuantLib::SampledCurve ( _grid ));
        
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
        if (_Cgrid != nullptr) _Cgrid->Unlock();
    }
}
Cephei::QL::Math::CSampledCurve::CSampledCurve (Microsoft::FSharp::Core::FSharpOption<UInt64>^ gridSize) 
{
	_pSpinlock = new boost::detail::spinlock ();
    try
    {
#ifdef HANDLE
        _phSampledCurve = NULL;
#endif
        QuantLib::Size _gridSize = 
            (Microsoft::FSharp::Core::FSharpOption<UInt64>::IsSome::get (gridSize) ? (QuantLib::Size)ValueHelper::Convert (gridSize->Value) : 0); //4
        _ppSampledCurve = new boost::shared_ptr<QuantLib::SampledCurve> (new QuantLib::SampledCurve ( _gridSize ));
        
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Math::CSampledCurve::CSampledCurve (boost::shared_ptr<QuantLib::SampledCurve>& childNative, Object^ owner) 
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phSampledCurve = NULL;
#endif
	_ppSampledCurve = &childNative;
    
}
Cephei::QL::Math::CSampledCurve::CSampledCurve (QuantLib::SampledCurve& childNative, Object^ owner) 
{
#ifdef HANDLE
	_phSampledCurve = NULL;
#endif
	_ppSampledCurve = new boost::shared_ptr<QuantLib::SampledCurve> (&childNative);
    
    _SampledCurveOwner = owner;
    
}

Cephei::QL::Math::CSampledCurve::CSampledCurve (CSampledCurve^ copy) 
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phSampledCurve = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppSampledCurve = new boost::shared_ptr<QuantLib::SampledCurve> (copy->GetShared());
        
    }
}
Cephei::QL::Math::CSampledCurve::CSampledCurve (PLATFORM::Type^ t) 
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phSampledCurve = NULL;
#endif
	if (!t->IsSubclassOf(CSampledCurve::typeid))
		throw REFNEW Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Math::CSampledCurve::CSampledCurve (QuantLib::Handle<QuantLib::SampledCurve>& childNative, Object^ owner)  
{
	_pSpinlock = new boost::detail::spinlock ();
	_phSampledCurve = &childNative;
	_ppSampledCurve = &static_cast<boost::shared_ptr<QuantLib::SampledCurve>>(childNative.currentLink());
    
    _SampledCurveOwner = owner;
}
Cephei::QL::Math::CSampledCurve::CSampledCurve (QuantLib::Handle<QuantLib::SampledCurve> childNative)  
{
	_pSpinlock = new boost::detail::spinlock ();
	_phSampledCurve = &childNative;
	_ppSampledCurve = &static_cast<boost::shared_ptr<QuantLib::SampledCurve>>(childNative.currentLink());
    
}
#endif
#ifdef STRUCT
Cephei::QL::Math::CSampledCurve::CSampledCurve (QuantLib::SampledCurve childNative)  
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phSampledCurve = NULL;
#endif
	_ppSampledCurve = new boost::shared_ptr<QuantLib::SampledCurve> (new QuantLib::SampledCurve (childNative));
    
}
#endif

Cephei::QL::Math::CSampledCurve::~CSampledCurve ()
{
	if (_pSpinlock != NULL)
    {
        delete _pSpinlock;
        _pSpinlock = NULL;
    }
    if (_ppSampledCurve != NULL)
    {
	    delete _ppSampledCurve;
        _ppSampledCurve = NULL;
    }
}
Cephei::QL::Math::CSampledCurve::!CSampledCurve ()
{
	if (_pSpinlock != NULL)
    {
        delete _pSpinlock;
    }
    if (_ppSampledCurve != NULL)
    {
	    delete _ppSampledCurve;
    }
}
QuantLib::SampledCurve& Cephei::QL::Math::CSampledCurve::GetReference ()
{
    if (_ppSampledCurve == NULL) throw REFNEW NativeNullException ();
	return **_ppSampledCurve;
}
boost::shared_ptr<QuantLib::SampledCurve>& Cephei::QL::Math::CSampledCurve::GetShared ()
{
    if (_ppSampledCurve == NULL) throw REFNEW NativeNullException ();
	return *_ppSampledCurve;
}
QuantLib::SampledCurve* Cephei::QL::Math::CSampledCurve::GetPointer ()
{
    if (_ppSampledCurve == NULL) throw REFNEW NativeNullException ();
	return &**_ppSampledCurve;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::SampledCurve>& Cephei::QL::Math::CSampledCurve::GetHandle ()
{
	if (_phSampledCurve == NULL)
	{
		_phSampledCurve = new Handle<QuantLib::SampledCurve> (*_ppSampledCurve);
	}
	return *_phSampledCurve;
}
#endif
bool Cephei::QL::Math::CSampledCurve::HasNative () 
{
	return (_ppSampledCurve != NULL);
}

Boolean Cephei::QL::Math::CSampledCurve::Empty::get ()
{
    try
    {
    	bool _rv = (bool)(*_ppSampledCurve)->empty ( );   
        Boolean _nrv = (Boolean)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Math::CSampledCurve::FirstDerivativeAtCenter::get ()
{
    try
    {
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppSampledCurve)->firstDerivativeAtCenter ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Math::IArray^ Cephei::QL::Math::CSampledCurve::Grid::get ()
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
    	QuantLib::Array& _rv = (QuantLib::Array&)(*_ppSampledCurve)->grid ( );   
        Cephei::QL::Math::CArray^ _nrv = REFNEW Cephei::QL::Math::CArray (_rv, this);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Math::CSampledCurve::GridValue (UInt64 i)
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
        QuantLib::Size _i = (QuantLib::Size)ValueHelper::Convert (i); //a
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppSampledCurve)->gridValue ( _i );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Math::ISampledCurve^ Cephei::QL::Math::CSampledCurve::Regrid (Cephei::QL::Math::IArray^ new_grid)
{
    CArray^ _Cnew_grid;
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
        _Cnew_grid = safe_cast<CArray^> (new_grid);
        _Cnew_grid->Lock();
        QuantLib::Array& _new_grid = static_cast<QuantLib::Array&> (_Cnew_grid->GetReference ()); 
    	(*_ppSampledCurve)->regrid ( _new_grid );
    	return this;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
        if (_Cnew_grid != nullptr) _Cnew_grid->Unlock();
    }
}
Cephei::QL::Math::ISampledCurve^ Cephei::QL::Math::CSampledCurve::RegridLogGrid (Double min, Double max)
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
        QuantLib::Real _min = (QuantLib::Real)ValueHelper::Convert (min); //a
        QuantLib::Real _max = (QuantLib::Real)ValueHelper::Convert (max); //a
    	(*_ppSampledCurve)->regridLogGrid ( _min,  _max );
    	return this;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Math::ISampledCurve^ Cephei::QL::Math::CSampledCurve::ScaleGrid (Double s)
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
        QuantLib::Real _s = (QuantLib::Real)ValueHelper::Convert (s); //a
    	(*_ppSampledCurve)->scaleGrid ( _s );
    	return this;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Math::CSampledCurve::SecondDerivativeAtCenter::get ()
{
    try
    {
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppSampledCurve)->secondDerivativeAtCenter ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Math::ISampledCurve^ Cephei::QL::Math::CSampledCurve::SetGrid (Cephei::QL::Math::IArray^ prm1)
{
    CArray^ _Cprm1;
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
        _Cprm1 = safe_cast<CArray^> (prm1);
        _Cprm1->Lock();
        QuantLib::Array& _prm1 = static_cast<QuantLib::Array&> (_Cprm1->GetReference ()); 
    	(*_ppSampledCurve)->setGrid ( _prm1 );
    	return this;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
        if (_Cprm1 != nullptr) _Cprm1->Unlock();
    }
}
Cephei::QL::Math::ISampledCurve^ Cephei::QL::Math::CSampledCurve::SetLogGrid (Double min, Double max)
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
        QuantLib::Real _min = (QuantLib::Real)ValueHelper::Convert (min); //a
        QuantLib::Real _max = (QuantLib::Real)ValueHelper::Convert (max); //a
    	(*_ppSampledCurve)->setLogGrid ( _min,  _max );
    	return this;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Math::ISampledCurve^ Cephei::QL::Math::CSampledCurve::SetValues (Cephei::QL::Math::IArray^ prm1)
{
    CArray^ _Cprm1;
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
        _Cprm1 = safe_cast<CArray^> (prm1);
        _Cprm1->Lock();
        QuantLib::Array& _prm1 = static_cast<QuantLib::Array&> (_Cprm1->GetReference ()); 
    	(*_ppSampledCurve)->setValues ( _prm1 );
    	return this;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
        if (_Cprm1 != nullptr) _Cprm1->Unlock();
    }
}
Cephei::QL::Math::ISampledCurve^ Cephei::QL::Math::CSampledCurve::ShiftGrid (Double s)
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
        QuantLib::Real _s = (QuantLib::Real)ValueHelper::Convert (s); //a
    	(*_ppSampledCurve)->shiftGrid ( _s );
    	return this;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
UInt64 Cephei::QL::Math::CSampledCurve::Size::get ()
{
    try
    {
    	QuantLib::Size _rv = (QuantLib::Size)(*_ppSampledCurve)->size ( );   
        UInt64 _nrv = _rv; //c1
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Math::ISampledCurve^ Cephei::QL::Math::CSampledCurve::Swap (Cephei::QL::Math::ISampledCurve^ prm1)
{
    CSampledCurve^ _Cprm1;
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
        _Cprm1 = safe_cast<CSampledCurve^> (prm1);
        _Cprm1->Lock();
        QuantLib::SampledCurve& _prm1 = static_cast<QuantLib::SampledCurve&> (_Cprm1->GetReference ()); 
    	(*_ppSampledCurve)->swap ( _prm1 );
    	return this;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
        if (_Cprm1 != nullptr) _Cprm1->Unlock();
    }
}
Double Cephei::QL::Math::CSampledCurve::Value (UInt64 i)
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
        QuantLib::Size _i = (QuantLib::Size)ValueHelper::Convert (i); //a
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppSampledCurve)->value ( _i );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Math::CSampledCurve::ValueAtCenter::get ()
{
    try
    {
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppSampledCurve)->valueAtCenter ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Math::IArray^ Cephei::QL::Math::CSampledCurve::Values::get ()
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
    	QuantLib::Array& _rv = (QuantLib::Array&)(*_ppSampledCurve)->values ( );   
        Cephei::QL::Math::CArray^ _nrv = REFNEW Cephei::QL::Math::CArray (_rv, this);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

Cephei::QL::Math::ISampledCurve^ Cephei::QL::Math::CSampledCurve_Factory::Create (Cephei::QL::Math::IArray^ grid)
{
    return REFNEW CSampledCurve ( grid);
}
Cephei::QL::Math::ISampledCurve^ Cephei::QL::Math::CSampledCurve_Factory::Create (Microsoft::FSharp::Core::FSharpOption<UInt64>^ gridSize)
{
    return REFNEW CSampledCurve ( gridSize);
}
